/* 1282. 用户分组 */
/**
 * @param {number[]} groupSizes
 * @return {number[][]}
 */
// 哈希表
var groupThePeople = function (groupSizes) {
	const groups = new Map()
	const n = groupSizes.length
	for (let i = 0; i < n; i++) {
		const size = groupSizes[i]
		if (!groups.has(size)) {
			groups.set(size, [])
		}
		groups.get(size).push(i)
	}
	const groupList = []
	for (const [size, peopele] of groups.entries()) {
		const groupCount = Math.floor(peopele.length / size)
		for (let i = 0; i < groupCount; i++) {
			const group = []
			const start = i * size
			for (let j = 0; j < size; j++) {
				group.push(peopele[start + j])
			}
			groupList.push(group)
		}
	}

	return groupList
}
groupThePeople([2, 1, 3, 3, 3, 2])
